package com.abocode.aichat.starter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(HttpProperties.class)
public class AutoConfiguration {
    @Autowired
    private HttpProperties properties;
    /***
     * 在Spring上下文中创建一个对象
     */
    @Bean
    @ConditionalOnMissingBean
    public AIChatClient init() {
        AIChatClient client = new AIChatClient();
        String url = properties.getUrl();
        client.setUrl(url);
        return client;
    }
}
